package com.ruoyi.system.util;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

import java.io.File;
import java.io.IOException;

public class Chart {
    private static final String outFilePath ="D:/chart.png";
    private static final int width = 900;

    private static final int height = 400;
    public static void main(String[] args) throws IOException {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(15, "收缩压", "收缩压");
        dataset.addValue(30, "舒张压", "舒张压");



        JFreeChart chart = ChartFactory.createBarChart3D(
                "",
                "血压",
                "number",
                dataset,
                PlotOrientation.VERTICAL,
                false, true, false);
        ChartFrame chartFrame = new ChartFrame("Test", chart);
        chartFrame.pack();
        ChartUtilities.saveChartAsPNG(new File(outFilePath), chart, width, height);
    }

}
